<?php
/**
 * @package YARBB
 * @copyright Авторские права (C) 2009 www.yar-it.com. Все права защищены.
 * @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
 * YARBB! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
 * Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл copyright.php.
 */
// запрет прямого доступа
defined( '_VALID_MOS' ) or die( 'Прямой доступ запрещен.' );

// Add/edit a group (stage 1)
if (isset($_POST['add_group']) || isset($_GET['edit_group'])) {
	if (isset($_POST['add_group'])) {
		$base_group = intval($_POST['base_group']);
		$sql = ('SELECT * FROM #__forum_groups WHERE g_id='.$base_group);
		$group_result = $database->setQuery($sql)->loadAssocList();
		$mode = 'add';
	}
	else	// We are editing a group
	{
		$group_id = intval($_GET['edit_group']);

		if ($group_id < 1)
			mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_404);
		$sql = ('SELECT * FROM #__forum_groups WHERE g_id='.$group_id);
		$result_if = $database->setQuery($sql)->loadResult();

		if (!$result_if)
			mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_404);
		$group_result = $database->setQuery($sql)->loadAssocList();
		$mode = 'edit';
	}

	$required_fields = array('req_title' => 'Group title');
	$focus_element = array('groups2', 'req_title');

	foreach ($group_result as $group)

		?>

<table class="adminheading">
	<tr>
		<th class="menus"> <span><?php echo _Y_GROPT; ?></span> </th>
	</tr>
</table>
<form id="groups2" method="post" action="<?php echo 'index2.php?option=com_forum&amp;task=groups'; ?>" onsubmit="return process_form(this)">
	<p>
		<input type="submit" name="add_edit_group" value=" <?php echo _CMN_SAVE; ?> " />&nbsp;
		<input onclick="javascript:history.go(-1)" name="" type="button" value="<?php echo _CMN_CANCEL; ?>" />
	</p>
	<input type="hidden" name="mode" value="<?php echo $mode ?>" />
	<?php if ($mode == 'edit'): ?>
	<input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
		<?php endif; ?>
	<?php if ($mode == 'add'): ?>
	<input type="hidden" name="base_group" value="<?php echo $base_group ?>" />
		<?php endif; ?>
	<table class="adminform">
		<tr>
			<th colspan="4"><?php echo _Y_GRPERM; ?></th>
		</tr>
		<tr>
			<td width="20%"><?php echo _Y_GRIDENF; ?></td>
			<td><input type="text" name="req_title" size="25" maxlength="50" value="<?php
	if ($mode == 'edit')
		echo yarbb_htmlspecialchars($group['g_title']);
					?>" tabindex="1" />
				<span> <?php echo mosToolTip(_Y_GRIDENF_D); ?></span> </td>
		</tr>
		<tr>
			<td><?php echo _Y_GRSHOW; ?></td>
			<td><input type="text" name="user_title" size="25" maxlength="50" value="<?php echo yarbb_htmlspecialchars($group['g_user_title']) ?>" tabindex="2" />
				<span><?php echo mosToolTip(_Y_GRSHOW_D); ?></span> </td>
		</tr>
		<tr>
			<td><?php echo _Y_GRCOLOR; ?></td>
			<td><input type="text" name="group_color" size="9" maxlength="7" value="<?php echo $group['g_color'] ?>" tabindex="25" />
				<span><?php echo mosToolTip(_Y_GRCOLOR_D); ?></span> </td>
		</tr>
	<?php if ($group['g_id'] != YARBB_ADMIN): ?>
		<tr>
			<td><?php echo _Y_GRREADF; ?></td>
			<td><input type="radio" name="read_board" value="1"<?php if ($group['g_read_board'] == '1') echo ' checked="checked"' ?> tabindex="3" />
				&nbsp; <strong> <?php echo _YES; ?> </strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="read_board" value="0"<?php if ($group['g_read_board'] == '0') echo ' checked="checked"' ?> tabindex="4" />
				&nbsp; <strong><?php echo _NO; ?></strong> <?php echo mosToolTip(_Y_GRREADF_D); ?> </td>
		</tr>
		<tr>
			<td><?php echo _Y_GRREADTOP; ?></td>
			<td><input type="radio" name="post_replies" value="1"<?php if ($group['g_post_replies'] == '1') echo ' checked="checked"' ?> tabindex="5" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="post_replies" value="0"<?php if ($group['g_post_replies'] == '0') echo ' checked="checked"' ?> tabindex="6" />
				&nbsp;<strong><?php echo _NO; ?></strong> </td>
		</tr>
		<tr>
			<td><?php echo _Y_GRNEWTOP; ?></td>
			<td><input type="radio" name="post_topics" value="1"<?php if ($group['g_post_topics'] == '1') echo ' checked="checked"' ?> tabindex="7" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="post_topics" value="0"<?php if ($group['g_post_topics'] == '0') echo ' checked="checked"' ?> tabindex="8" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<tr>
			<td><?php echo _Y_GRNEWPOL; ?></td>
			<td><input type="radio" name="post_polls" value="1"<?php if ($group['g_post_polls'] == '1') echo ' checked="checked"' ?> tabindex="7" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="post_polls" value="0"<?php if ($group['g_post_polls'] == '0') echo ' checked="checked"' ?> tabindex="8" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<?php if ($group['g_id'] != YARBB_MOD): ?>
		<tr>
			<td><?php echo _Y_GRGLMODER; ?></td>
			<td><input type="radio" name="global_moderation" value="1"<?php if ($group['g_global_moderation'] == '1') echo ' checked="checked"' ?> />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="global_moderation" value="0"<?php if ($group['g_global_moderation'] == '0') echo ' checked="checked"' ?> />
				&nbsp;<strong><?php echo _NO; ?></strong> </td>
		</tr>
		<?php endif; ?>
		<?php if ($group['g_id'] != YARBB_GUEST): ?>
		<tr>
			<td><?php echo _Y_GRMAINPOS; ?></td>
			<td><input type="radio" name="edit_posts" value="1"<?php if ($group['g_edit_posts'] == '1') echo ' checked="checked"' ?> tabindex="11" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="edit_posts" value="0"<?php if ($group['g_edit_posts'] == '0') echo ' checked="checked"' ?> tabindex="12" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<tr>
			<td><?php echo _Y_GRDELMPOST; ?></td>
			<td><input type="radio" name="delete_posts" value="1"<?php if ($group['g_delete_posts'] == '1') echo ' checked="checked"' ?> tabindex="13" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="delete_posts" value="0"<?php if ($group['g_delete_posts'] == '0') echo ' checked="checked"' ?> tabindex="14" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<tr>
			<td><?php echo _Y_GRDELTOPTH ?></td>
			<td><input type="radio" name="delete_topics" value="1"<?php if ($group['g_delete_topics'] == '1') echo ' checked="checked"' ?> tabindex="15" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="delete_topics" value="0"<?php if ($group['g_delete_topics'] == '0') echo ' checked="checked"' ?> tabindex="16" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<tr>
			<td><?php echo _Y_GRSETUSER; ?></td>
			<td><input type="radio" name="set_title" value="1"<?php if ($group['g_set_title'] == '1') echo ' checked="checked"' ?> tabindex="17" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="set_title" value="0"<?php if ($group['g_set_title'] == '0') echo ' checked="checked"' ?> tabindex="18" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<?php endif; ?>
		<tr>
			<td><?php echo _Y_GRUSSEARCH; ?></td>
			<td><input type="radio" name="search" value="1"<?php if ($group['g_search'] == '1') echo ' checked="checked"' ?> tabindex="19" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="search" value="0"<?php if ($group['g_search'] == '0') echo ' checked="checked"' ?> tabindex="20" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<tr>
			<td><?php echo _Y_GRSERCHLIST; ?></td>
			<td><input type="radio" name="search_users" value="1"<?php if ($group['g_search_users'] == '1') echo ' checked="checked"' ?> tabindex="21" />
				&nbsp;<strong><?php echo _YES; ?></strong>&nbsp;&nbsp;&nbsp;
				<input type="radio" name="search_users" value="0"<?php if ($group['g_search_users'] == '0') echo ' checked="checked"' ?> tabindex="22" />
				&nbsp;<strong><?php echo _NO; ?></strong></td>
		</tr>
		<?php if ($group['g_id'] != YARBB_GUEST): ?>
		<tr>
			<td><?php echo _Y_GRNAMETIME; ?></td>
			<td><input type="text" name="edit_subjects_interval" size="5" maxlength="5" value="<?php echo $group['g_edit_subjects_interval'] ?>" tabindex="23" />
				<span><?php echo mosToolTip(_Y_GRNAMETIME_D); ?></span> </td>
		</tr>
		<tr>
			<td><?php echo _Y_GRANTFLOOD; ?></td>
			<td><input type="text" name="post_flood" size="5" maxlength="4" value="<?php echo $group['g_post_flood'] ?>" tabindex="24" />
				<span><?php echo mosToolTip(_Y_GRANTFLOOD_D); ?></span> </td>
		</tr>
		<tr>
			<td><?php echo _Y_GRANTSEARSH; ?></td>
			<td><input type="text" name="search_flood" size="5" maxlength="4" value="<?php echo $group['g_search_flood'] ?>" tabindex="25" />
				<span><?php echo mosToolTip(_Y_GRANTSEARSH_D); ?></span> </td>
		</tr>
	</table>
		<?php endif; ?>
	<?php endif; ?>
		<?php if ($group['g_id'] == YARBB_MOD ): ?>
			<?php echo _Y_GRNOTE; ?>
		<?php endif; ?>
</form>
		<?php

}
// Добавить группу, шаг 2
else if (isset($_POST['add_edit_group'])) {
	// Это админ группа? (изменить правила)
	$is_admin_group = (isset($_POST['group_id']) && $_POST['group_id'] == YARBB_ADMIN) ? true : false;
	$title = trim($_POST['req_title']);
	$user_title = trim($_POST['user_title']);
	$group_color = trim($_POST['group_color']);
	$read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1';
	$post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1';
	$post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1';

	$post_polls = isset($_POST['post_polls']) ? intval($_POST['post_polls']) : '1';
	$edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0';
	$delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0';
	$delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0';
	$set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0';
	$search = isset($_POST['search']) ? intval($_POST['search']) : '1';
	$search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1';
	$edit_subjects_interval = isset($_POST['edit_subjects_interval']) ? intval($_POST['edit_subjects_interval']) : '0';
	$post_flood = isset($_POST['post_flood']) ? intval($_POST['post_flood']) : '0';
	$search_flood = isset($_POST['search_flood']) ? intval($_POST['search_flood']) : '0';
	$global_moderation = isset($_POST['global_moderation']) ? $_POST['global_moderation'] : '0';

	if ($group_color != '') {
		if (!preg_match('{^(#){1}([a-fA-F0-9]){6}$}', $group_color))
			mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_GRNONCOLOR);
	}
	if ($title == '')
		mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_GRNONIDENT);
	$user_title = ($user_title != '') ? '\''.$database->getEscaped($user_title).'\'' : 'NULL';
	if ($_POST['mode'] == 'add') {
		$sql = ('SELECT 1 FROM #__forum_groups WHERE g_title=\''.$database->getEscaped($title).'\'');
		$result_rows = $database->setQuery($sql)->loadResult();
		if ($result_rows)
			mosRedirect( 'index2.php?option=com_forum&amp;task=groups',_Y_GRNONIDENTALL.''.yarbb_htmlspecialchars($title).'.');


		$sql = ('INSERT INTO #__forum_groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood, g_global_moderation, g_color) VALUES(\''.$database->getEscaped($title).'\', '.$user_title.', '.$read_board.', '.$post_replies.', '.$post_topics.', '.$post_polls.', '.$edit_posts.', '.$delete_posts.', '.$delete_topics.', '.$set_title.', '.$search.', '.$search_users.', '.$edit_subjects_interval.', '.$post_flood.', '.$search_flood.', '.$global_moderation.', \''.$group_color.'\')');
		$database->setQuery($sql);
		$database->Query($sql);
		$new_group_id = $database->insertid();


		$sql = ('SELECT forum_id, read_forum, post_replies, post_topics, post_polls
				FROM #__forum_forum_perms WHERE group_id='.intval($_POST['base_group']));
		$cur_forum_perm_result = $database->setQuery($sql)->loadAssocList();
		foreach ($cur_forum_perm_result as $cur_forum_perm)
			$sql = ('INSERT INTO #__forum_forum_perms (group_id, forum_id, read_forum, post_replies, post_topics, post_polls) VALUES('.$new_group_id.', '.$cur_forum_perm['forum_id'].', '.$cur_forum_perm['read_forum'].', '.$cur_forum_perm['post_replies'].', '.$cur_forum_perm['post_topics'].', '.$cur_forum_perm['post_polls'].')');
		$database->setQuery($sql);
		$database->Query($sql);
	}
	else {
		$sql = ('SELECT 1 FROM #__forum_groups WHERE g_title=\''.$database->getEscaped($title).'\' AND g_id!='.intval($_POST['group_id']));
		$result_row = $database->setQuery($sql)->loadResult();
		if ($result_row) {
			mosRedirect( 'index2.php?option=com_forum&amp;task=groups',_Y_GRNONIDENTALL.''.yarbb_htmlspecialchars($title).'.');
		} else {

		$sql = ('UPDATE #__forum_groups SET g_title=\''.$database->getEscaped($title).'\', g_user_title='.$user_title.', g_read_board='.$read_board.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_post_polls='.$post_polls.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_edit_subjects_interval='.$edit_subjects_interval.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.', g_global_moderation='.$global_moderation.', g_color=\''.$group_color.'\' WHERE g_id='.$_POST['group_id']);
		$database->setQuery($sql);
		$database->Query($sql);
	}
	}
	// Regenerate the quickjump cache
	require_once $yarbb_admin_path.'/include/cache.php';
	generate_quickjump_cache();
	mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _O_GROUP.(($_POST['mode'] == 'edit') ? '&nbsp;'._Y_GRUPDATES.'' : '&nbsp;'._Y_GRADDSUS.''));
}
// Группа по умолчанию
else if (isset($_POST['set_default_group'])) {
	$group_id = intval($_POST['default_group']);
	if ($group_id < 4)
		mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_404);
	$sql = ('UPDATE #__forum_config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'');
	$database->setQuery($sql);
	$database->Query($sql);
	// Regenerate the config cache
	require_once $yarbb_admin_path.'/include/cache.php';
	generate_config_cache();
	mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_GRDEFSUS);
}
// Remove a group
else if (isset($_GET['del_group'])) {
	$group_id = intval($_GET['del_group']);
	if ($group_id < 5)
		mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_404);
	// Make sure we don't remove the default group
	if ($group_id == $yarbb_config['o_default_user_group'])
		mosRedirect( 'index2.php?option=com_forum&amp;task=groups', _Y_GRDEFNONDEL);
	// Проверить, имеет ли группа пользователей
	$sql = ('SELECT g.g_title, COUNT(u.id)
					FROM #__forum_groups AS g 
					INNER JOIN #__forum_users AS u 
					ON g.g_id=u.group_id 
					WHERE g.g_id='.$group_id.' 
					GROUP BY g.g_id, g_title');
	$chek_user_result = $database->setQuery($sql)->loadRow();
	// Если группа не имеет никаких пользователей или если мы уже выбрали группу, чтобы переместить пользователей
	if (!$chek_user_result || isset($_POST['del_group'])) {
		if (isset($_POST['del_group'])) {
			$move_to_group = intval($_POST['move_to_group']);
			$sql = ('UPDATE #__forum_users SET group_id='.$move_to_group.' WHERE group_id='.$group_id);
			$database->setQuery($sql);
			$database->Query($sql);
		}
		// Удалить группу и разрешения форума для группы
		$sql = ('DELETE FROM #__forum_groups WHERE g_id='.$group_id);
		$database->setQuery($sql);
		$database->Query($sql);
		$sql = ('DELETE FROM #__forum_forum_perms WHERE group_id='.$group_id);
		$database->setQuery($sql);
		$database->Query($sql);
		// Regenerate the quickjump cache
		require_once $yarbb_admin_path.'/include/cache.php';
		generate_quickjump_cache();
		mosRedirect('index2.php?option=com_forum&amp;task=groups', _SUCCESS_DELETION);
	}
	list($group_title, $group_members) = $chek_user_result;

	?>
<table class="adminheading">
	<tr>
		<th class="menus"> <span><?php echo _Y_GROUPDELITE; ?></span> </th>
	</tr>
</table>


<form id="groups" method="post" action="<?php echo 'index2.php?option=com_forum&amp;task=groups&amp;del_group='.$group_id; ?>">
	<table class="adminform">
		<tr>
			<th colspan="4">
	<?php echo _Y_GRMOVE; ?></th></tr>

		<tr><td><p><?php echo _O_GROUP; ?> "<?php echo yarbb_htmlspecialchars($group_title) ?>" <?php echo _Y_GRSODERG; ?> <?php echo $group_members ?> <?php echo _Y_GRSODERG2; ?>.</p>
	<?php echo _Y_GRMOVETO; ?>
				<select name="move_to_group">
	<?php
	$sql = ('SELECT g_id, g_title FROM #__forum_groups
					WHERE g_id!='.YARBB_GUEST.' 
					AND g_id!='.$group_id.' 
					ORDER BY g_title');
	$cur_group_result = $database->setQuery($sql)->loadAssocList();
	foreach ($cur_group_result as $cur_group) {
						if ($cur_group['g_id'] == YARBB_MEMBER)	// Pre-select the pre-defined Members group
			echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.yarbb_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
							else
								echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.yarbb_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
						}
						?>
				</select>

				<p>
					<input type="submit" name="del_group" value="<?php echo _E_REMOVE; ?>" />
				</p>
			</td></tr></table>
</form>

						<?php
					}else {
						?>
<table class="adminheading">
	<tr>
		<th class="menus"> <span><?php echo _Y_GRADDPERMGLOB; ?></span> </th>
	</tr>
</table>

<form id="groups" method="post" action="<?php echo 'index2.php?option=com_forum&amp;task=groups&amp;action=foo'; ?>">


	<table class="adminform">
		<tr><th colspan="4"><?php echo _E_ADD;?></th></tr>
		<tr>
			<td width="20%">

				<input type="submit" name="add_group" value=" <?php echo _E_ADD; ?> " tabindex="2" />
			</td>
			<td><select id="base_group" name="base_group" tabindex="1">
	<?php
	$sql = ('SELECT g_id, g_title FROM #__forum_groups WHERE g_id>'.YARBB_GUEST.' ORDER BY g_title');
	$cur_group_result = $database->setQuery($sql)->loadAssocList();
	foreach ($cur_group_result as $cur_group) {
		if ($cur_group['g_id'] == $yarbb_config['o_default_user_group'])
			echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.yarbb_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
		else
			echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.yarbb_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
	}
	?>
				</select>
				<span><?php echo mosToolTip(_Y_GRADDPERMGLOB_D); ?></span> </td>
		</tr>
	</table>



	<table class="adminform">
		<tr><th colspan="4"><?php echo _Y_GRDEFOULTON; ?></th></tr>
		<tr>
			<td width="20%">

				<input type="submit" name="set_default_group" value=" <?php echo _DEFAULT; ?> " tabindex="4" />
			</td>
			<td><select id="default_group" name="default_group" tabindex="3">
	<?php
	$sql = ('SELECT g_id, g_title FROM #__forum_groups WHERE g_id>'.YARBB_GUEST.' ORDER BY g_title');
	$cur_group_result = $database->setQuery($sql)->loadAssocList();
	foreach ($cur_group_result as $cur_group) {
		if ($cur_group['g_id'] == $yarbb_config['o_default_user_group'])
			echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.yarbb_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
		else
			echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.yarbb_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
	}
	?>
				</select>
				<span><?php echo mosToolTip(_Y_GRDEFOULTON_D); ?></span> </td>
		</tr>
	</table>

</form>

<table class="adminform">
	<tr><th colspan="4"><?php echo _Y_GRREDAKDEL; ?>&nbsp;<?php echo mosToolTip(_Y_GRREDAKDEL_D); ?></th></tr>

	<?php
	$sql = ('SELECT g_id, g_title FROM #__forum_groups ORDER BY g_id');
	$database->setQuery($sql);
	$cur_group_result = $database->loadAssocList();
	foreach ($cur_group_result as $cur_group)
		echo "\t\t\t\t\t\t\t\t".'<tr class="row0"><td width="20%"><a href="'.'index2.php?option=com_forum&amp;task=groups&amp;edit_group='.$cur_group['g_id'].'">'._CHANGE.'</a>'.(($cur_group['g_id'] > YARBB_MEMBER) ? ' - <a href="'.'index2.php?option=com_forum&amp;task=groups&amp;del_group='.$cur_group['g_id'].'">'._E_REMOVE.'</a>' : '').'</td><td>'.yarbb_htmlspecialchars($cur_group['g_title']).'</td></tr>'."\n";
	?>
</table>
	<?php
} ?>